from moviepy import *


def 将数字人视频桌子上添加logo(image_path: str, video_path: str, output_path: str, fps=24):
    logo_image = ImageClip(image_path)
    logo_image = logo_image.resized(height=200)
    video = VideoFileClip(video_path)

    # 水平剧中，距离最下面50px
    logo_image = logo_image.with_position(("center", video.size[1] - 100 - logo_image.size[1]))


    # 合并
    final = CompositeVideoClip([video, logo_image.with_duration(video.duration)])
    final.show()
    final.write_videofile(output_path, codec='libx264', fps=24, ffmpeg_params=['-auto-alt-ref', '0'])
    # final.write_videofile(output_path, fps=fps, ffmpeg_params=['-auto-alt-ref', '0'])


if __name__ == '__main__':
    将数字人视频桌子上添加logo("../sucai/logo/亨得利.png", "../sucai/video/baige.webm",
                               "../sucai/video/hengdeli.mp4")